package com.liyunc.demo.comp.common.rest.response;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class GeneralResponse<T> extends AbstractResponse {
    private T payload;

    public GeneralResponse(T payload) {
        this.payload = payload;
    }

    public GeneralResponse(int code, String message, T payload) {
        super(code, message);
        this.payload = payload;
    }

    public static <T> GeneralResponse<T> of(int code, String message, T payload) {
        return new GeneralResponse<T>(code, message, payload);
    }

    public static <T> GeneralResponse<T> of(T payload) {
        return new GeneralResponse<>(0, null, payload);
    }
}
